package apof.model
{
	public class BudgetStc extends ApofModel
	{
		public var bid:int;
		public var name:String;
		public var month:int;
		public var year:int;
		
		public var items:Array=new Array;
		
		public static function onInit():Boolean {
			var pt:Object=prototype;
			pt.classname="BudgetStc";
			pt.fields=["name","bid","month","year"];
			pt.fieldTypes=["VARCHAR(40)","int","int","int"];
			pt.primaryKey=["bid"];
			pt.foreignKey={"items":	{"linkto":BudgetItem,	"aggregate":true,	"ref":"items",	"peerlink":"biid"}};
			return true;
		}
		
		public function get amount():Number {
			var sum:Number=0;
			for each(var bi:BudgetItem in items) {
				sum+=bi.amount;
			}
			return sum;
		}
		
		public function get acture():Number {
			var sum:Number=0;
			for each(var bi:BudgetItem in items) {
				sum+=bi.acture;
			}
			return sum;
		} 
		
		
		public override function get classInfo():Object {return prototype;}
		public static function get classInfo():Object {return prototype;}
	}
}